package com.hs.wa.controller;



import com.hs.wa.service.RuleConfigService;

import com.springnew.model.Ruleconfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin
public class RuleConfigController {
    @Autowired(required=true)
    private RuleConfigService ruleConfigService;

    @PostMapping("/getRuleConfigAxios")
    @ResponseBody  /* 解决 Unknown return value type: java.lang.Boolean*/
    public  List<Ruleconfig> getRuleConfigAxios() {
        boolean flag = false;
        List<Ruleconfig> ruleconfigs;
        ruleconfigs = ruleConfigService.selectRuleConfig();

        return ruleconfigs;
    }

    @PostMapping("/addRuleConfigAxios")
    @ResponseBody  /* 解决 Unknown return value type: java.lang.Boolean*/
    public ResponseEntity addRuleConfigAxios(Ruleconfig ruleconfig) {
        boolean flag = ruleConfigService.insertRuleConfig(ruleconfig);

        if (flag) {
            return ResponseEntity.ok().build();
        }
        return ResponseEntity.badRequest().build();
    }
}
